<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%"
      row-key="id"
      border
      :tree-props="{ children: 'children' }"
    >
      <el-table-column prop="id" label="编号"></el-table-column>
      <el-table-column prop="title" label="轮播图标签"></el-table-column>
      <el-table-column label="图片">
        <!-- 图片 -->
         <template slot-scope="scope">
          <img :src="$pre+scope.row.img" alt="">
        </template> 
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status == 1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="handleEdit(scope)">编辑</el-button>
          <del-btn @confirm="del(scope)"></del-btn>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import { reqbannerdelete } from "../../../http/api";
import { successAlert } from "../../../utils/alert";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({
      list: "banner/list"
    })
  },
  methods: {
    ...mapActions({
      reqList: "banner/reqList"
    }),
    async del(scope) {
      let res = await reqbannerdelete({
        id: scope.row.id
      });
      if (res.data.code == 200) {
        successAlert(res.data.msg);
        this.reqList();
      }
    },
    handleEdit(scope){
        this.$emit("willUpdate",scope.row.id)
    }
  },
  mounted() {
    this.reqList();
  }
};
</script>

<style>
img{
  width: 100px;
  height: 100px;
}
</style>